package com.wan37.logic.chat.handler;

import com.wan37.logic.chat.cache.ChatCache;
import com.wan37.logic.chat.util.ChatRouteUtil;
import com.wan37.logic.component.Worker;
import com.wan37.logic.domain.vo.MessageVO;
import com.wan37.logic.global.reference.SpringContextHolder;
import com.wan37.logic.handler.MsgHandler;
import com.wan37.protobuf.constant.PtoNum;

/**
 * 获取历史世界聊天消息
 *
 * @author : luoyong
 * @date : 2020-07-15 20:44
 **/
public class CGameWorldPlayerChatOldHandler extends MsgHandler {
    private ChatRouteUtil chatRouteUtil;
    private ChatCache chatCache;

    /**
     * MsgHandler构造函数
     *
     * @param messageVO
     */
    public CGameWorldPlayerChatOldHandler(MessageVO messageVO) {
        super(messageVO);
        this.chatRouteUtil = SpringContextHolder.getBean("chatRouteUtil");
        this.chatCache = SpringContextHolder.getBean("chatCache");
    }

    @Override
    public void execute(Worker worker) throws Exception {
        /**
         * 返回缓存的世界消息
         */
        chatRouteUtil.sendChatResponse(PtoNum.WORLDPLAYERCHATOLD, messageVO.getUserId(), chatCache.getWorldChatVOList());
    }
}
